<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单详情页面</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/util.js"></script>
    <script>
    let orderId=0;
    window.onload=function () {
        orderId = getQuery("orderId");
        showOrder(orderId);
    }
    async function showOrder(id){
        let info =await ajaxGet("/order/findById",{id});
        alert(JSON.stringify(info));

        let str =`<div style="text-align: left;width: 400px;">
            订单号&emsp;&emsp;${info.id}<br>
            收货人&emsp;&emsp;${info.receiver}<br>
            收货地址&emsp;${info.address}<br>
            收货人电话 ${info.phone}<br>
            下单时间&emsp;${info.date}<br>
            订单总价&emsp;${info.orderMoney}<br>
            订单状态&emsp;${info.status}<br></div>`;
        $("orderDiv").innerHTML=str;

        let productList="";
        for (let i = 0; i <info.infoList.length; i++) {
            let obj=info.infoList[i];
            productList =`<tr>
            <td>${obj.id}</td>
            <td>${obj.product.name}</td>
            <td>${obj.product.price}</td>
            <td>${obj.num}</td></tr>`;
        }
        $("data").innerHTML=productList;
    }
    async function sendProduct(){
        let info =await ajaxGet("/order/send",{id:orderId});
        if (info == "ok"){
            showOrder(orderId);
        }
       await returnProduct();
    }
    async function returnProduct(){
        location.href="/html/manager/pressOrder.html";
    }

    </script>
</head>
<body>
    <div id="orderDiv"></div>
    <h2>订单明细</h2>
    <table border="1" cellspacing="0" width="60%">
        <thead><tr><th>商品编号</th><th>商品名</th><th>单价</th><th>购买数量</th></tr></thead>
        <tbody id="data"></tbody>
    </table>
    <input type="button" value="发货" onclick="sendProduct()">
    <input type="button" value="返回" onclick="returnProduct()">
</body>
</html>